package aad.storyboard.controller;


public class AudioPlayingState implements AudioState

{

        //define a instance to hold reference of Context Object (AudioPlayer)

        private AudioPlayer audioPlayer;

        

		public AudioPlayingState(AudioPlayer a){

            System.out.println("=== Playing State ===");

            audioPlayer = a;
        }

        //implementation of IState methods
        @Override
		public void playAudio()
        {
        	System.out.println("Player already Playing");
        }

        @Override
		public void pauseAudio()
        {
        	System.out.println("PAUSED STATE: ---");
        	audioPlayer.getPlayer().pause();   		
            audioPlayer.setNewState(audioPlayer.getPausedState());
        }

        @Override
		public void stopAudio()
        {
        	System.out.println("STOPPED STATE: ---");
        	audioPlayer.getPlayer().stop();		
    		audioPlayer.getPlayer().reset();	
            audioPlayer.setNewState(audioPlayer.getStoppedState());
        }

		@Override
		public void seekToPosition(int position) {
			audioPlayer.getPlayer().seekTo(position);
			audioPlayer.setNewState(audioPlayer.getPlayingState());
			
		}

    }
